<template>
	<div @touchmove.stop.prevent="moveHandle">
		<u-popup :show="show2" mode="center">
			<view class="box-tk">
				<view class="view1">医嘱详细信息 </view>
				<view class="xian"></view>
				<scroll-view scroll-y="true" v-if="reportObj.children"
					:class="['box-xis',reportObj.children.length > 3 ? 'box-aigicon':'']">
					<view class="xis-title" v-for="(el,index) in reportObj.children" :key="index">
						{{el.remark + ' ' + el.many +'.0' + el.packunit.trim() + ' ' + (el.dosage.trim() ? '【'+el.dosage+'】' : el.dosage)}}
					</view>
					<view class="box-img"></view>
					<view class="xis-hend" :class="[reportObj.children.length>1 ? 'xis-avicon' :'']">
						<view class="hend-title">
							<text>频度：</text>{{reportObj.children[0].frequency}}
						</view>
						<view class="hend-title">
							<text>用法：</text>{{reportObj.children[0].admission}}
						</view>
						<view class="hend-title" v-if="!reportShow">
							<text>医生：</text>{{reportObj.children[0].empname}}
						</view>
						<view class="hend-title" v-if="reportObj.children[0].ordertype!==undefined">
							<text>长期/临时：</text>{{reportObj.children[0].ordertype.trim() == 'S'?'临':reportObj.children[0].ordertype.trim() == 'R' ? '长':reportObj.children[0].ordertype.trim() == 'C'?'出':reportObj.children[0].ordertype.trim()}}
						</view>
						<view class="hend-title" v-else>
							<text>长期/临时：</text>
						</view>
						<view class="hend-title" v-if="reportShow" style="padding-bottom: 10px;">
							<text>时间：</text>{{reportObj.children[0].plandate}}
						</view>
						<view class="hend-title" v-else>
							<text>开始时间：</text>{{reportObj.children[0].datestart}}
						</view>
						<view class="hend-title" v-if="reportObj.children[0].datestop !==undefined ">
							<text>结束时间：</text>{{reportObj.children[0].datestop !==undefined ?reportObj.children[0].datestop.replace(/\//g, '-'):reportObj.children[0].datestop}}
						</view>
					</view>
				</scroll-view>
				<view class="tk-heard" v-if="reportObj.children">
					<u-button v-if="reportObj.children[0].prtype == 'NSC' && reportObj.children[0].doflag == '1'"
						type="primary" style="margin-right: 10px;" text="停医嘱" class="btn" color="#f00"
						@tap="StopMedical"></u-button>
					<u-button v-if="reportShow" type="primary" style="margin-right: 10px;" text="执行" class="btn"
						color="#82ECC3" @tap="StopImplement"></u-button>
					<u-button type="primary" text="取消" class="btn" color="#FF6E91" @tap="cancel"></u-button>
				</view>
			</view>
		</u-popup>
	</div>
</template>

<script>
	import {
		NSC_Stop,
		EMR_Nursing_SaveOrder_New_NS1
	} from "@/api/user.js"
	import {
		mapMutations,
		mapState
	} from "vuex";
	export default {
		props: {
			show2: {
				type: Boolean,
				default: false
			},
			reportObj: {
				type: Object,
				default: {
					ordertype: ''
				}
			},
			reportShow: {
				type: Boolean
			}
		},

		data() {
			return {
				// show2: true
				Lthegiht: ''
			}
		},
		methods: {
			cancel() {
				this.$emit('cancelTails', false);
				// this.show2 = false
			},
			async StopMedical() {
				const user = uni.getStorageSync('userInfo')
				const obj = uni.getStorageSync('deleteObj')
				const data = {
					HosKind: user.hoscode,
					mrn: obj.MRN,
					series: obj.SERIES,
					orderno: this.reportObj.children[0].orderno,
					sOperJp: user.sPassword,
				}
				const res = await this.$http.NSC_Stop(data)
				if (res[0].result == '1') {
					await this.$emit('cancelTails', false);
					await this.$emit('StopMedicalit');
					await uni.showToast({
						title: '执行成功！',
						duration: 1000
					});
				} else {
					uni.showToast({
						title: '执行失败！',
						duration: 1000,
						icon: 'error'
					});
				}
			},
			async StopImplement() {
				try {
					let user = uni.getStorageSync('userInfo')
					let obj = this.reportObj.children
					const data = {
						HosKind: user.hoscode,
						sExemode: 'PDA点击',
						mrn: obj[0].mrn,
						stay: 'I',
						series: obj[0].series,
						orderdordnarray: obj[0].orderdordn,
						bedid: obj[0].bedid,
						pname: obj[0].pname,
						operdept: user.HosKind,
						operjp: user.sUserid,
						iMark: obj[0].iMark,
						iautocharge: obj[0].iautocharge,
						exeflag3: ''
					}
					const res = await this.$http.EMR_Nursing_SaveOrder_New_NS1(data)
					this.$emit('cancelTails', false, 'queren', res);
				} catch (e) {
					//TODO handle the exception
				}
				// this.$emit('cancelTails', false);
				// console.log('执行医嘱');
			},
			moveHandle() {}
		}
	}
</script>


<style scoped lang="scss">
	::v-deep .u-popup {
		.u-fade-enter-active {
			z-index: 99 !important;
		}
	}

	.box-tk {
		width: 670rpx;
		// height: 212rpx;
		// background: #FFFFFF;
		border-radius: 8rpx;
		position: relative;
		padding-bottom: 15rpx;

		.view1 {
			font-size: 36rpx;
			font-family: SourceHanSansCN-Medium, SourceHanSansCN;
			font-weight: 500;
			color: #333333;
			line-height: 40px;
			text-align: center;
		}

		.xian {
			position: absolute;
			width: 100%;
			height: 2rpx;
			background: #7AD9DF;
			left: 0;
			top: 80rpx;
			// opacity: 0.19;
			// opacity: 0.19;
			// margin: 14rpx 0;
		}

		.box-xis ::v-deep {
			width: 97%;
			// height: 92%;
			background: #B0E9EC;
			margin: 20rpx auto 0;
			padding-bottom: 12rpx;
			position: relative;
			border-radius: 12rpx;

			.uni-scroll-view-content {
				width: 100% !important;
			}

			.box-img {
				position: absolute;
				right: 0;
				top: 0;
				width: 58px;
				height: 28px;
				background: url('../../static/img/coagulation.svg') no-repeat;
				background-size: 100% auto;
				box-shadow: 5px -3px 8px 0px #D4D9D9;
			}

			.xis-title {
				font-size: 16px;
				font-family: SourceHanSansCN-Normal, SourceHanSansCN;
				font-weight: 400;
				color: #333333;
				padding: 4rpx 18rpx;
				line-height: 28px;
				// height: 28px;
				width: 80%;
			}

			.xis-hend {
				// width: 303px;
				width: 96%;
				// height: calc(100%);
				// height: 81%;
				margin: 0 auto;
				// height: 228px;
				background: #F6FEFF;
				border-radius: 6px;
				opacity: 0.95;

				text {
					font-size: 32rpx;
					font-family: SourceHanSansCN-Medium, SourceHanSansCN;
					font-weight: 500;
					color: #333333;
					line-height: 48rpx;
				}

				.hend-title {
					font-size: 32rpx;
					font-family: SourceHanSansCN-Medium, SourceHanSansCN;
					// font-weight: 500;
					color: #333333;
					line-height: 48rpx;
					padding: 20rpx;

					&:nth-child(-n+5) {
						padding-bottom: 0;
					}
				}
			}
		}

		.tk-heard {
			display: flex;
			// height: calc(100% - 636rpx);
			align-items: center;
			margin: 16rpx auto 0;
			width: 97%;
		}

		.tk-heard ::v-deep {
			.u-button__text {
				font-size: 36rpx !important;
				font-family: SourceHanSansCN-Medium, SourceHanSansCN;
				font-weight: 500;
				color: #FFFFFF;
				line-height: 54rpx;
				letter-spacing: 28rpx;
			}
		}
	}

	// .xis-avicon {
	// 	height: auto !important;
	// }

	.box-aigicon {
		height: 320px;
	}
</style>
